<?php
/**
 * Created by PhpStorm.
 * User: admin
 * Date: 2018/5/30
 * Time: 15:13
 */
namespace App\Modules\User\Models;

use Illuminate\Database\Eloquent\Model;
use DB;

class UserAverageRecommend extends Model{
    /**
     * 自荐表被查看次数
     */
    static function RecommendAllReadTimes(){
        $readInfo = DB::table('self_recommendations')
            ->select(DB::raw("count(id) as cid"))
            ->where([
                ['is_view','=',1]
            ])
            ->first();
        if($readInfo){
            $readCount = $readInfo->cid;
        }
        return $readCount;
    }

    /**
     * 用户自荐表数
     */
    static function RecommendAllTimes(){
        $readInfo = DB::table('self_recommendations')
            ->select(DB::raw("count(id) as cid"))
            ->first();
        if($readInfo){
            $readCount = $readInfo->cid;
        }
        return $readCount;
    }
    /**
     * 用户自荐成功次数
     */
    static function RecommendAllSuccessTimes(){
        $readInfo = DB::table('self_recommendations')
            ->select(DB::raw("count(id) as cid"))
            ->where([
                ['status','=','SUCCESS']
            ])
            ->first();
        $successCount = 0;
        if($readInfo){
            $successCount = $readInfo->cid;
        }
        return $successCount;
    }
    /**
     * 获取自荐用户数
     */
    static function RecommendUserNum(){
        $readInfo = DB::table('self_recommendations')
            ->select(DB::raw("count(uid) as cid"))
            ->groupBy('uid')
            ->first();
        $successCount = 0;
        if($readInfo){
            $successCount = $readInfo->cid;
        }
        return $successCount;
    }
}